
local textureIdp = SDL_calloc(1,0x10);
local imgData = SDL_malloc(100*100*4);
SDL_memset4(imgData,0xff0000FF,60*100);
local value = 0x10000000;
viewport = SDL_calloc(4*4*2,1);
viewport = toArray(viewport,4);
function glTest2dTexure()
   if(textureId==nil)then
        --glPushAttrib( GL_ENABLE_BIT );
        glDisable( GL_DEPTH_TEST );
        --glDisable( GL_CULL_FACE );
        glEnable( GL_TEXTURE_2D );
        
        --glEnable(GL_BLEND);
        --glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
        --glBlendFunc(GL_SRC_COLOR, GL_SRC_COLOR)
        glEnable(GL_ALPHA_TEST);
        glAlphaFunc(GL_GREATER, 0.35); 
        
        
        -- glViewport( 0, 0, 600, 480 );
        -- glMatrixMode( GL_PROJECTION );
        -- glLoadIdentity();
        -- glOrtho(
		 -- 1.0,
		 -- 2.0,
		 -- 2.0,
		 -- 1.0,
		-- 0.0,
		-- 1.0 );
        -- glMatrixMode(GL_MODELVIEW);
        -- glLoadIdentity();
        
       
       glGenTextures(1,textureIdp);
       textureId = dr(textureIdp,1,8);
       --print("init id",textureId);
       glBindTexture(GL_TEXTURE_2D, textureId);
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
       
       glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,100,100,0,GL_RGBA,GL_UNSIGNED_BYTE,imgData);
   end
   
   data = imgData;
   width = 100;
   height = 100;
   --glClearColor(0.5,0.0,0.0,0.0);
   
   -- glViewport(viewport[0],viewport[1],viewport[2],viewport[3]);
   
   -- glMatrixMode(GL_PROJECTION);
   -- glLoadIdentity();
   
   -- glOrtho(0,viewport[2],viewport[3],0,0,1.0);
   
   -- glEnable(GL_TEXTURE_2D);
   
   glBindTexture(GL_TEXTURE_2D, textureId);
   glTexSubImage2D(GL_TEXTURE_2D,0,0,0,width,height,GL_RGBA,GL_UNSIGNED_BYTE,data );
   glBegin( GL_QUADS );
   
     glTexCoord2f( 0.0, 0.0);
     glVertex2f( 0.0, 0.0, 0.0 );
   
    glTexCoord2f( 1.0, 0.0 );
    glVertex2f( 1.0, 0, 0 );
    
    glTexCoord2f( 1.0, 1.0 );
	glVertex2f( 1.0, 1.0, 0 );

	glTexCoord2f( 0.0, 1.0 );
	glVertex2f( 0, 1.0, 0 );
	glEnd();
    
    glDrawPixels(100,100,GL_RGBA,GL_UNSIGNED_BYTE,imgData);
   
   glDisable(GL_TEXTURE_2D);
   --glFlush();
end




